package info.tanke;

import info.helper.MMath;
import java.awt.event.ItemEvent;
import java.util.ArrayList;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JSlider;
import javax.swing.JToggleButton;

public class TankeFrame extends javax.swing.JFrame {
    long letztesAutoAnkunft=0;
    int speedMultiplier=10;
    int newCarRate=2000;
    int newCarRunner=0;
    Waschanlage wan;
    Zapfsäule z1;
    Zapfsäule z2;
    Zapfsäule z3;
    private boolean pauseNewCar=false;
    
    public TankeFrame() {
        initComponents();
        wan=new Waschanlage(pnWasch1,"Waschanlage");
        z1=new Zapfsäule(pnTank1,"Zapfhahn 1");
        z2=new Zapfsäule(pnTank2,"Zapfhahn 2");
        z3=new Zapfsäule(pnTank3,"Zapfhahn 3");
        Thread u=new Thread(new UpdateRunner());
        u.start();
    }
    
    private class Waschanlage extends TankstellenObjekt{
        public Waschanlage(JPanel p,String name) {
            super(p,name);
        }
        
    }
    
    private class Zapfsäule extends TankstellenObjekt{
        public Zapfsäule(JPanel p,String name) {
            super(p,name);
            this.arbeitsZeit=250;
        }
        
        public int getQueueLength(){
            return schl.gibLänge();
        }
        
    }
    
    private class TankstellenObjekt {
        Schlange schl;
        int arbeitsZeit=500;
        int waschRunner=0;
        JPanel p;
        String name;
        
        public TankstellenObjekt(JPanel p,String name){
            schl=new Schlange(name);
            this.name=name;
            this.p=p;
        }
        
        public void enqueue(Auto a){
            schl.enqueue(a);
        }
        
        public void update(long time){
            ((JProgressBar)p.getComponent(1)).setMaximum(arbeitsZeit*speedMultiplier);
            if(!schl.istLeer()){
                Auto erstes=(Auto) schl.erstes();
                if(erstes.active){
                    if(time-erstes.activeStart>arbeitsZeit*speedMultiplier){
                        schl.dequeue();
                    }
                } else {
                    waschRunner++;
                    erstes.startAction();
                }
            }   
            //Render
            String s="";
            Schlange mwasch=(Schlange)schl.clone();
            if(!schl.istLeer()){
                Auto a =(Auto)mwasch.erstes();
                s+=" In Bearbeitung: "+a.ident;
                mwasch.aktuellesEntfernen();
                s+="Warteschlange: ";
                if(a.active){
                    ((JLabel)p.getComponent(2)).setText(name+" bearbeitet Auto #"+waschRunner+" : "+a.ident);
                    ((JProgressBar)p.getComponent(1)).setValue((int) (time-a.activeStart));
                }
                while(!mwasch.istLeer()){
                    Auto aa =(Auto)mwasch.aktuellesElement();
                    s+=" Auto: "+aa.ident;
                    mwasch.aktuellesEntfernen();
                }
            } else {
                ((JProgressBar)p.getComponent(1)).setValue((int) (0));
                ((JLabel)p.getComponent(2)).setText(name+" hat #"+waschRunner+" Autos bearbeitet");
                s="Keine Autos in der Warteschlange";
            }
            ((JLabel)p.getComponent(3)).setText(s);
        }
    }

    
    public class UpdateRunner implements Runnable {
        @Override
        public void run() {
            while(true){
                long time=System.currentTimeMillis();
                
                //Auto Ankunft
                if(time-letztesAutoAnkunft>newCarRate&&!pauseNewCar){
                    Auto a=new Auto();
                    newCarRunner++;
                    lbCarStat.setText(newCarRunner+" Autos angekommen");
                    if(a.ziel.equals("waschen")){
                        wan.enqueue(a);
                    } else if(a.ziel.equals("tanken")){
                        int[] zapfen=new int[]{z1.getQueueLength(),z2.getQueueLength(),z3.getQueueLength()};
                        int index=MMath.getSmallestElementIndex(zapfen);
                        if(index==0){
                            z1.enqueue(a);
                        } else if(index==1){
                            z2.enqueue(a);
                        } else if(index==2){
                            z3.enqueue(a);
                        }
                    }
                    letztesAutoAnkunft=time;
                }
                pbNextCar.setValue((int) (time-letztesAutoAnkunft));
                //Waschen
                wan.update(time);
                z1.update(time);
                z2.update(time);
                z3.update(time);
         
            }
        }
    }
    

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lbTitel = new javax.swing.JLabel();
        pnWasch1 = new javax.swing.JPanel();
        pbWasch1 = new javax.swing.JProgressBar();
        lbWasch1 = new javax.swing.JLabel();
        lbWaschStat1 = new javax.swing.JLabel();
        spWasch1 = new javax.swing.JSeparator();
        pnTank1 = new javax.swing.JPanel();
        pbTank1 = new javax.swing.JProgressBar();
        lbTank1 = new javax.swing.JLabel();
        lbTankStat1 = new javax.swing.JLabel();
        spTank1 = new javax.swing.JSeparator();
        pnSett = new javax.swing.JPanel();
        pbNextCar = new javax.swing.JProgressBar();
        slNextCar = new javax.swing.JSlider();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        slSpeed = new javax.swing.JSlider();
        jToggleButton1 = new javax.swing.JToggleButton();
        lbCarStat = new javax.swing.JLabel();
        pnTank2 = new javax.swing.JPanel();
        pbTank2 = new javax.swing.JProgressBar();
        lbTank2 = new javax.swing.JLabel();
        lbTankStat2 = new javax.swing.JLabel();
        spTank2 = new javax.swing.JSeparator();
        pnTank3 = new javax.swing.JPanel();
        pbTank3 = new javax.swing.JProgressBar();
        lbTank3 = new javax.swing.JLabel();
        lbTankStat3 = new javax.swing.JLabel();
        spTank3 = new javax.swing.JSeparator();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        lbTitel.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        lbTitel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbTitel.setText("Tanke");

        lbWasch1.setText("Waschenlage #1");

        lbWaschStat1.setText("jLabel2");

        javax.swing.GroupLayout pnWasch1Layout = new javax.swing.GroupLayout(pnWasch1);
        pnWasch1.setLayout(pnWasch1Layout);
        pnWasch1Layout.setHorizontalGroup(
            pnWasch1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnWasch1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnWasch1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(spWasch1)
                    .addGroup(pnWasch1Layout.createSequentialGroup()
                        .addGroup(pnWasch1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(pbWasch1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(pnWasch1Layout.createSequentialGroup()
                                .addGroup(pnWasch1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lbWasch1)
                                    .addComponent(lbWaschStat1))
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addContainerGap())))
        );
        pnWasch1Layout.setVerticalGroup(
            pnWasch1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnWasch1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pbWasch1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbWasch1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbWaschStat1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(spWasch1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        lbTank1.setText("Zapfsäule #1");

        lbTankStat1.setText("jLabel2");

        javax.swing.GroupLayout pnTank1Layout = new javax.swing.GroupLayout(pnTank1);
        pnTank1.setLayout(pnTank1Layout);
        pnTank1Layout.setHorizontalGroup(
            pnTank1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnTank1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnTank1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(spTank1)
                    .addGroup(pnTank1Layout.createSequentialGroup()
                        .addGroup(pnTank1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(pbTank1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(pnTank1Layout.createSequentialGroup()
                                .addGroup(pnTank1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lbTank1)
                                    .addComponent(lbTankStat1))
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addContainerGap())))
        );
        pnTank1Layout.setVerticalGroup(
            pnTank1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnTank1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pbTank1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbTank1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbTankStat1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(spTank1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        slNextCar.setMajorTickSpacing(500);
        slNextCar.setMaximum(5000);
        slNextCar.setMinimum(100);
        slNextCar.setMinorTickSpacing(250);
        slNextCar.setPaintLabels(true);
        slNextCar.setPaintTicks(true);
        slNextCar.setToolTipText("");
        slNextCar.setValue(2000);
        slNextCar.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                slNextCarStateChanged(evt);
            }
        });

        jLabel1.setText("Neues Auto Rate");

        jLabel2.setText("Arbeitsgeschwindigkeit");

        slSpeed.setMajorTickSpacing(5);
        slSpeed.setMaximum(20);
        slSpeed.setPaintLabels(true);
        slSpeed.setPaintTicks(true);
        slSpeed.setToolTipText("");
        slSpeed.setValue(10);
        slSpeed.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                slSpeedStateChanged(evt);
            }
        });

        jToggleButton1.setText("Pause");
        jToggleButton1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jToggleButton1StateChanged(evt);
            }
        });

        javax.swing.GroupLayout pnSettLayout = new javax.swing.GroupLayout(pnSett);
        pnSett.setLayout(pnSettLayout);
        pnSettLayout.setHorizontalGroup(
            pnSettLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnSettLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnSettLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pbNextCar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(pnSettLayout.createSequentialGroup()
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jToggleButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(slNextCar, javax.swing.GroupLayout.DEFAULT_SIZE, 683, Short.MAX_VALUE))
                    .addGroup(pnSettLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(slSpeed, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        pnSettLayout.setVerticalGroup(
            pnSettLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnSettLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(pnSettLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(slSpeed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnSettLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnSettLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(slNextCar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel1))
                    .addComponent(jToggleButton1, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pbNextCar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        lbCarStat.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lbCarStat.setText("jLabel3");

        lbTank2.setText("Zapfsäule #2");

        lbTankStat2.setText("jLabel2");

        javax.swing.GroupLayout pnTank2Layout = new javax.swing.GroupLayout(pnTank2);
        pnTank2.setLayout(pnTank2Layout);
        pnTank2Layout.setHorizontalGroup(
            pnTank2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnTank2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnTank2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(spTank2)
                    .addGroup(pnTank2Layout.createSequentialGroup()
                        .addGroup(pnTank2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(pbTank2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(pnTank2Layout.createSequentialGroup()
                                .addGroup(pnTank2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lbTank2)
                                    .addComponent(lbTankStat2))
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addContainerGap())))
        );
        pnTank2Layout.setVerticalGroup(
            pnTank2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnTank2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pbTank2, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbTank2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbTankStat2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(spTank2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        lbTank3.setText("Zapfsäule #2");

        lbTankStat3.setText("jLabel2");

        javax.swing.GroupLayout pnTank3Layout = new javax.swing.GroupLayout(pnTank3);
        pnTank3.setLayout(pnTank3Layout);
        pnTank3Layout.setHorizontalGroup(
            pnTank3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnTank3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnTank3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(spTank3)
                    .addGroup(pnTank3Layout.createSequentialGroup()
                        .addGroup(pnTank3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(pbTank3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(pnTank3Layout.createSequentialGroup()
                                .addGroup(pnTank3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lbTank3)
                                    .addComponent(lbTankStat3))
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addContainerGap())))
        );
        pnTank3Layout.setVerticalGroup(
            pnTank3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnTank3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pbTank3, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbTank3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbTankStat3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(spTank3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnSett, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lbCarStat)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbTitel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(pnWasch1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(pnTank1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(pnTank2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(pnTank3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbTitel, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbCarStat))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnWasch1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnTank1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnTank2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnTank3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(pnSett, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void slNextCarStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_slNextCarStateChanged
       JSlider sl=(JSlider)evt.getSource();
       this.newCarRate=sl.getValue();
       pbNextCar.setMaximum(sl.getValue());
        
    }//GEN-LAST:event_slNextCarStateChanged

    private void slSpeedStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_slSpeedStateChanged
        JSlider sl=(JSlider)evt.getSource();
        this.speedMultiplier=sl.getValue();
    }//GEN-LAST:event_slSpeedStateChanged

    private void jToggleButton1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jToggleButton1StateChanged
        if(((JToggleButton)evt.getSource()).isSelected()){
            pauseNewCar=true;
        } else {
            pauseNewCar=false;
        }
    }//GEN-LAST:event_jToggleButton1StateChanged

    public static void main(String args[]) {
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TankeFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TankeFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TankeFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TankeFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TankeFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JToggleButton jToggleButton1;
    private javax.swing.JLabel lbCarStat;
    private javax.swing.JLabel lbTank1;
    private javax.swing.JLabel lbTank2;
    private javax.swing.JLabel lbTank3;
    private javax.swing.JLabel lbTankStat1;
    private javax.swing.JLabel lbTankStat2;
    private javax.swing.JLabel lbTankStat3;
    private javax.swing.JLabel lbTitel;
    private javax.swing.JLabel lbWasch1;
    private javax.swing.JLabel lbWaschStat1;
    private javax.swing.JProgressBar pbNextCar;
    private javax.swing.JProgressBar pbTank1;
    private javax.swing.JProgressBar pbTank2;
    private javax.swing.JProgressBar pbTank3;
    private javax.swing.JProgressBar pbWasch1;
    private javax.swing.JPanel pnSett;
    private javax.swing.JPanel pnTank1;
    private javax.swing.JPanel pnTank2;
    private javax.swing.JPanel pnTank3;
    private javax.swing.JPanel pnWasch1;
    private javax.swing.JSlider slNextCar;
    private javax.swing.JSlider slSpeed;
    private javax.swing.JSeparator spTank1;
    private javax.swing.JSeparator spTank2;
    private javax.swing.JSeparator spTank3;
    private javax.swing.JSeparator spWasch1;
    // End of variables declaration//GEN-END:variables
}
